﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.Mvc;
using ForzaGT3.Data;

namespace ForzaGT3.Controllers
{
    public partial class ContentController : Controller
    {
        //
        // GET: /Content/

        public virtual ActionResult Index()
        {
            return View();
        }

        public virtual ActionResult TopNavigation()
        {
            return PartialView(MVC.Content.Views._TopNavigation);
        }

        public virtual ActionResult LanguageSelector()
        {
            return PartialView(MVC.Content.Views._LanguageSelector);
        }

        [HttpGet]
        public virtual ActionResult NewsletterSubscriber()
        {
            return PartialView(MVC.Content.Views._NewsletterSubscriber);
        }

        [HttpPost]
        public virtual ActionResult NewsletterSubscriber(NewsletterSubscriber model)
        {

            return PartialView(MVC.Content.Views._NewsletterSubscriber);
        }

        public virtual ActionResult SeriesSelector()
        {
            IEnumerable<Series> data = Series.GetAll()
                .Where(x => x.StartDate.Date > DateTime.Now.Date)
                .OrderBy(x=>x.StartDate);

            ViewData.Model = data;

            return PartialView(MVC.Content.Views._SeriesSelector);
        }

        public virtual ActionResult PartnerList()
        {
            IEnumerable<Partner> data = Partner.GetAll();
            ViewData.Model = data;
            return PartialView(MVC.Content.Views._PartnerList);
        }

        public virtual ActionResult SocialMediaConnect()
        {
            return PartialView(MVC.Content.Views._SocialMediaConnect);
        }

        public virtual ActionResult UpcomingRacePreview()
        {
            Series upcomingRace = Series.GetUpcomingRace();
            ViewData.Model = upcomingRace;
            return PartialView(MVC.Content.Views._UpcomingRacePreview);
        }

        public virtual ActionResult GalleryPreview()
        {
            IEnumerable<Gallery> images = Gallery.GetAll().Take(4);
            ViewData.Model = images;
            return PartialView(MVC.Content.Views._GalleryPreview);
        }

        public virtual ActionResult StandingsPreview()
        {
            IEnumerable<Driver> drivers = Driver.GetAll().OrderByDescending(x => x.Points).Take(10);
            ViewData.Model = drivers;
            return PartialView(MVC.Content.Views._StandingsPreview);
        }
    }
}
